{{template "header.html" .}}

<h1>Validation sample 3</h1>

{{if .errors}}
<div class="error">
	<h2>Oops, please correct these errors</h2>
</div>
{{end}}

<form action="/Sample3/HandleSubmit" method="POST">
	<fieldset>
		<legend>User informations</legend>

		<div class="field">
			<label for="username">Desired username :</label>
			<input type="text" id="username" name="user.Username" value="{{index .flash "user.Username"}}" class="{{errorClass "user.Username" .}}"/>
			<span class="error">{{index .errors "user.Username"}}</span>
		</div>

		<div class="field">
			<label for="firstname">First name :</label>
			<input type="text" id="firstname" name="user.FirstName" value="{{index .flash "user.FirstName"}}" class="{{errorClass "user.FirstName" .}}"/>
			<span class="error">{{index .errors "user.FirstName"}}</span>
		</div>

		<div class="field">
			<label for="lastname">Last name :</label>
			<input type="text" id="lastname" name="user.LastName" value="{{index .flash "user.LastName"}}" class="{{errorClass "user.LastName" .}}"/>
			<span class="error">{{.errors.lastname}}</span>
			<span class="error">{{index .errors "user.LastName"}}</span>
		</div>

		<div class="field">
			<label for="age">Age :</label>
			<input type="text" id="age" name="user.Age" value="{{index .flash "user.Age"}}" class="{{errorClass "user.Age" .}}"/>
			<span class="error">{{index .errors "user.Age"}}</span>
		</div>

	</fieldset>
	<fieldset>
		<legend>Password</legend>

		<div class="field">
			<label for="password">Password :</label>
			<input type="password" id="password" name="user.Password" value="{{index .flash "user.Password"}}" class="{{errorClass "user.Password" .}}"/>
			<span class="error">{{index .errors "user.Password"}}</span>
		</div>

		<div class="field">
			<label for="passwordConfirm">Confirm password :</label>
			<input type="password" id="password" name="user.PasswordConfirm" value="{{index .flash "user.PasswordConfirm"}}" class="{{errorClass "user.PasswordConfirm" .}}"/>
			<span class="error">{{index .errors "user.PasswordConfirm"}}</span>
		</div>

	</fieldset>
	<fieldset>
		<legend>Email</legend>

		<div class="field">
			<label for="email">Email address :</label>
			<input type="text" id="email" name="user.Email" size="30" value="{{index .flash "user.Email"}}" class="{{errorClass "user.Email" .}}"/>
			<span class="error">{{index .errors "user.Email"}}</span>
		</div>

		<div class="field">
			<label for="emailConfirm">Confirm email address :</label>
			<input type="text" id="email" name="user.EmailConfirm" size="30" value="{{index .flash "user.EmailConfirm"}}" class="{{errorClass "user.EmailConfirm" .}}"/>
			<span class="error">{{index .errors "user.EmailConfirm"}}</span>
		</div>

	</fieldset>
	<fieldset>
		<legend>Conditions</legend>

		<div class="infos">
			Checking this box indicates that you accept terms of use.
			If you do not accept these terms, do not use this website :
		</div>

		<div class="field">
			<label for="termsOfUse">I accept terms of use :</label>
			<input id="termsOfUse" type="checkbox" value="true" name="user.TermsOfUse" {{if index .flash "user.TermsOfUse"}}checked="true"{{end}} class="{{errorClass "user.TermsOfUse" .}}"/>
			<span class="error">{{index .errors "user.TermsOfUse"}}</span>
		</div>

	</fieldset>

	<input type="submit" class="submit" value="Join !" />
</form>

{{template "footer.html" .}}
